/**
 * Created by Demon-pro on 2015/6/28.
 */
var Calculate = function () {
    var getChooseCalculate = function () {
          return {
              modelState: $("#modelState").is(':checked') ? "1" : "0",
              model: $("#model").val(),
              caseId: $("#caseId").val()
          }
    }
    return {
        init: function () {
            $("#nextPage").on("click", function () {
                location.href = basePath + "mill/heat?menuId=38"
            })
            $("#modelState").bind("click", function () {
                Calculate.modelStateClick($(this))
            })
        },
        calculateSave: function () {
            $.ajax({
                url: basePath + "mill/calculate/calculateSave",
                type: "post",
                dataType: "json",
                data: getChooseCalculate(),
                success: function (data) {
                    if (data.ok) {
                        formSub(basePath + "mill/calculate?menuId=37&message=success")
                    } else  {
                        toast.error(data.returnMsg);
                        return false;
                    }
                }
            })
        },
        modelStateClick: function (obj) {
           //如果选中的情况
           if (obj.is(':checked')) {
               $("#model").attr("disabled", false)
           } else {
               $("#model").attr("disabled", true)
           }
       }
    }

}();